#!/bin/bash

echo "===================================="
echo "  Claude 前端开发实战指南"
echo "  正在启动演示应用..."
echo "===================================="
echo ""

# 检查Node环境
echo "[1/3] 检查Node环境..."
if ! command -v node &> /dev/null; then
    echo "错误: 未检测到Node.js，请先安装Node.js"
    echo "下载地址: https://nodejs.org/"
    exit 1
fi
echo "Node.js已安装: $(node --version)"

echo ""
echo "[2/3] 安装依赖包..."
if [ ! -d "node_modules" ]; then
    echo "首次运行，正在安装依赖..."
    npm install
else
    echo "依赖已安装"
fi

echo ""
echo "[3/3] 启动开发服务器..."
echo ""
echo "===================================="
echo "  应用将在浏览器中自动打开"
echo "  地址: http://localhost:3000"
echo ""
echo "  使用说明:"
echo "  - 使用方向键或空格键导航"
echo "  - 按F键进入全屏"
echo "  - 按ESC退出全屏"
echo ""
echo "  按 Ctrl+C 停止服务器"
echo "===================================="
echo ""

npm run dev